#!/bin/bash

echo "========================================"
echo "     Mars3D GIS Desktop 安装脚本"
echo "========================================"
echo

# 检查Node.js是否安装
if ! command -v node &> /dev/null; then
    echo "❌ 错误: 未检测到Node.js，请先安装Node.js"
    echo "请访问 https://nodejs.org 下载安装Node.js"
    exit 1
fi

echo "✅ Node.js 已安装"
node --version

# 检查npm版本
echo
echo "📦 检查npm版本..."
npm --version

# 安装依赖
echo
echo "📥 开始安装项目依赖..."
echo "这可能需要几分钟时间，请耐心等待..."
echo

npm install

if [ $? -ne 0 ]; then
    echo
    echo "❌ 依赖安装失败，请检查网络连接或尝试以下命令:"
    echo "npm config set registry https://registry.npmmirror.com"
    echo "然后重新运行此脚本"
    exit 1
fi

echo
echo "✅ 依赖安装成功!"
echo
echo "🚀 您现在可以使用以下命令:"
echo
echo "  开发模式运行:"
echo "  npm run electron:serve"
echo
echo "  构建应用:"
echo "  npm run electron:build"
echo
echo "========================================"
echo "安装完成!"